/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.test.app.email;

import javax.mail.internet.MimeMessage;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;

/**
 *
 * @author darshana
 */
public class Preparator implements MimeMessagePreparator {

    @Override
    public void prepare(MimeMessage mimeMessage) throws Exception {
        MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
        mimeMessageHelper.setFrom("darshana@rcapl.com");
        mimeMessageHelper.setTo("thusira14@gmail.com");
        mimeMessageHelper.setSubject("Linklk");
        StringBuilder text = new StringBuilder();
        text.append("<html>");
        text.append("<body>");
        text.append("<h3>Hi User</h3>");
        text.append("<p>Test mail from LINKLK</p>");
        text.append("<p><img src=\"cid:greetingImage\"/></p>");
        text.append("</body>");
        text.append("</html>");

        mimeMessageHelper.setText(text.toString(), true);
        FileSystemResource inlineContent = new FileSystemResource("/resources/images/pic.gif");
        mimeMessageHelper.addInline("greetingImage", inlineContent);
    }
}
